package com.tong.lib_base.base;


import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;



/**
 * @author liuzhitong
 * @descreb fragment的基类，放入一些预加载数据
 * 用于MVVM框架
 * */
public abstract class AbcFragmentVM extends Fragment {
    protected View mView;

    @Nullable
    @Override
    public View onCreateView(@Nullable LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        Log.e("abcFragment",getClass().getSimpleName());
        if (container == null) {
            return null;
        }
        if (mView == null) {
            initData();
            mView = initBinding(inflater);
            initViews(mView);
        }
        return mView;
    }

    /**
     * 1加载布局之前的一些数据或者变量
     *
     */
    public abstract void initData();

    /**
     * @dep  3处理逻辑
     */
    public abstract void initViews(View view);
    /**
     * 2加载UI
     */
    public abstract View initBinding(@NonNull LayoutInflater inflater);

    @Override
    public void onDestroy() {
        super.onDestroy();
    }

}
